package com.itany.springcloud.springcloudnacosconfig;

import com.itany.springcloud.springcloudnacosconfig.bean.SomeBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import javax.sql.DataSource;

@SpringBootApplication
public class SpringcloudNacosConfigApplication {

    public static void main(String[] args) throws Exception{
        ConfigurableApplicationContext ac=SpringApplication.run(SpringcloudNacosConfigApplication.class, args);

        SomeBean someBean=ac.getBean(SomeBean.class);

        System.out.println("someBean = " + someBean);

        String str=ac.getEnvironment().getProperty("some.str");
        String var=ac.getEnvironment().getProperty("some.var");

        System.out.println("var = " + var);
        System.out.println("var = " + var);

//        System.out.println(ac.getBean(DataSource.class));
        DataSource dataSource=ac.getBean(DataSource.class);
        System.out.println(dataSource.getConnection());
        System.out.println(dataSource.getConnection());
        System.out.println(dataSource.getConnection());
    }

}
